import {Component,OnInit} from '@angular/core'
import {HeroService} from './hero.service'
import {Hero} from './hero'
@Component({
    selector:'my-dashboard',
    templateUrl:'./dashboard.component.html',
    styleUrls:['./dashboard.component.css']
})

export class DashboardComponent implements OnInit{
    Heroes:Hero[]=[];
    constructor(private heroService:HeroService){}

    ngOnInit():void{
        this.getHeroes();
    }

    getHeroes():void{
        this.heroService.getHeroes().then((res:Hero[])=>{
            this.Heroes=res.slice(1,5)
        }
        ).catch(rej=>{
            console.log(rej);
        })
    }
}